<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 第一种方式,用一个字符串或者下划线方式
    //   var person = (function () {
    //     let _name = "name";
    //     function person(name) {
    //       this[_name] = name;
    //     }
    //     person.prototype.getName = function () {
    //       return this[_name];
    //     };
    //     return person
    //   })();
      //闭包 浪费内存，无法实现共享
    //   var person =(function () {
    //     function Person(name) {
    //         this.getName=function(){
    //             return name
    //         }
    //     }
    //     return Person
    //   }())

    //symbol 
    var person = (function () {
        var nameSymbol = Symbol('name');
        function Person(name) {
            this[nameSymbol]=name
        }
        person.prototype.getName = function () {
          return this[nameSymbol];
        };
        return Person
    }())
    </script>
  </body>
</html>
